<template>
	<view class="tui-center">
		<uni-nav-bar fixed left-icon="back" :title="titleTex"></uni-nav-bar>

		<view v-if="showContent" class="detail">
			<view class="v_title">{{title}}</view>
			<view v-html="content"></view>
		</view>

		<view v-else class="tui-notice">
			<view class="tui-notice-box" v-for="(item, index) in list" :key="index">
				<view class="tui-notice-title">
					{{item.title}}
				</view>
				<view class="tui-flex">
					<view>{{item.updateTime}}</view>
					<view @tap="detail(item)">查看详情</view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
                content: '',
                showContent: false,
                titleTex: '通知',
				title: ''
			}
		},
		onLoad() {
			this.getList()
		},
		methods: {
            getList() {
                this.$api.api('notice').then(res => {
                    this.list = res.data.list
                }).catch(error => {
                    this.$api.msg(error.message)
                })
            },
            detail(item) {
                this.showContent = true
                this.content = item.content
				this.title = item.title
                this.titleTex = '详情'
            }
		}
	}
</script>

<style lang="scss">
	.detail {
		background: #fff;
		padding: 30rpx;
	}
	.v_title {
		font-size: 40rpx;
		color: #000;
		text-align: center;
		padding-bottom: 15rpx;
	}
	.tui-notice {
		padding: 10rpx 40rpx;
		.tui-notice-box {
			margin-top: 50rpx;
			box-shadow: 0 2rpx 8rpx 4rpx #F1F1F1;
			border-radius: 10rpx;
			background: #fff;
			color: #333;
			.tui-notice-title {
				padding: 30rpx 14rpx 14rpx;
				font-size: 36rpx;
				border-bottom: 2rpx solid #eee;
			}
			.tui-flex{
				justify-content: space-between;
				padding: 14rpx 14rpx 30rpx;
				color: #999;
			}
		}
	}
</style>
